package cn.bon.common.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * @author: dronff
 * @description:
 * @CreateTime: 2023/12/6 22:24
 **/
@Component
public class TimeMetaObjectFillHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        this.fillStrategy(metaObject, "createTime", LocalDateTime.now());
        this.fillStrategy(metaObject, "updateTime", LocalDateTime.now());
    }

    @Override
    public void updateFill(MetaObject metaObject) {
//        this.fillStrategy(metaObject, "updateTime", LocalDateTime.now());
        setFieldValByName("updateTime",LocalDateTime.now(),metaObject);
    }
}
